Skip to content

fix(build): gate _CRT_SECURE_NO_WARNINGS on WIN32, not MSVC - #111

Merged
16bit-ykiko merged 1 commit into
mainfrom
fix/crt-secure-no-warnings-gate
Apr 18, 2026
Merged

fix(build): gate _CRT_SECURE_NO_WARNINGS on WIN32, not MSVC#111
16bit-ykiko merged 1 commit into
mainfrom
fix/crt-secure-no-warnings-gate

Conversation

@16bit-ykiko

Copy link
Copy Markdown
Member

Summary

On Windows, any Clang-based toolchain that links against MSVC CRT (ucrt/msvcrt) — clang-cl, clang-native via -Xclang --dependent-lib=msvcrt, MSVC itself — triggers the _CRT_INSECURE_DEPRECATE(fopen_s) attribute on functions like fopen. Kotatsu's own src/ipc/recording_transport.cpp uses std::fopen, so that attribute produces a -Wdeprecated-declarations warning during kotatsu's internal build unless _CRT_SECURE_NO_WARNINGS is defined.

The existing gate $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS> only applies to MSVC proper and clang-cl. Under clang-native on Windows (e.g. conda-forge clangxx, which downstream CI matrices use), ${MSVC} is FALSE, the define is skipped, and the warning fires on kotatsu's own TU.

Before #109, this was tolerable — it was only a warning. #109 introduced -Wall -Wextra -Werror into kota::project_options, which promoted the warning to an error. Result: every downstream consumer (e.g. clice#428) started failing its Windows-clang CI on kotatsu's internal compile the moment it picked up main.

Fix

Gate the define on WIN32 instead of MSVC. MinGW gets the define too, but its CRT doesn't emit _CRT_INSECURE_DEPRECATE, so it's a harmless no-op there.

Test plan

  • Root cause verified by diffing compile output for _deps/*/src/ipc/recording_transport.cpp.obj:
    • Apr 11 (pre-refactor: rename eventide -> kotatsu #109) clice main CI: warning: 'fopen' is deprecated … [-Wdeprecated-declarations] (non-fatal)
    • Apr 17 (post-refactor: rename eventide -> kotatsu #109) clice PR CI: error: 'fopen' is deprecated … [-Werror,-Wdeprecated-declarations] (fatal)
    • Both built under same clang++.exe -Xclang --dependent-lib=msvcrt command line; the only relevant delta was -Werror being introduced.
  • Local Windows build with this fix + clice PR #428 — env install in progress; I'll verify there is no further Windows-only regression once done and update this PR if anything surfaces.

Why not fix recording_transport.cpp to use fopen_s / std::ofstream instead?

Viable, but scope creep — the define is how every MSVC-CRT consumer silences deprecation spam on CRT functions kotatsu uses today and may use tomorrow. One-line gate fix is tighter.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@16bit-ykiko has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da62be79-6f4a-44c6-8f52-e768d2f008b6

📥 Commits

Reviewing files that changed from the base of the PR and between 0d361e7 and 09bde67.

📒 Files selected for processing (1)
  • CMakeLists.txt
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/crt-secure-no-warnings-gate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

kota_project_options guarded _CRT_SECURE_NO_WARNINGS with
$<$<BOOL:${MSVC}>:...>, which is FALSE for clang++ targeting Windows
natively (e.g. conda-forge clangxx used by downstream CI). That
compiler still links ucrt/msvcrt via -Xclang --dependent-lib=msvcrt,
so MSVC CRT headers still emit _CRT_INSECURE_DEPRECATE on fopen,
strcpy, etc. Previously this only surfaced as a warning, but
#109 (rename + introduce -Wall -Wextra -Werror in project_options)
promoted it to an error, breaking kotatsu's own
recording_transport.cpp compile on clang-native Windows as soon as
downstream projects fetched kotatsu main.

Gate the define on WIN32 instead, so cl/clang-cl/clang-native all
get it. MinGW also picks it up but its CRT doesn't emit the macro,
so the define is a harmless no-op there.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@16bit-ykiko
16bit-ykiko force-pushed the fix/crt-secure-no-warnings-gate branch from bd2b8c8 to 09bde67 Compare April 18, 2026 04:27
@16bit-ykiko
16bit-ykiko merged commit 243c7d0 into main Apr 18, 2026
27 checks passed
@16bit-ykiko
16bit-ykiko deleted the fix/crt-secure-no-warnings-gate branch April 18, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant